import {schema2component} from '../AMISRenderer';

export default schema2component(
    {
        type: 'dialog',
        title: '新增页面',
        body: {
            type: 'form',
            controls: [
                {
                    type: 'text',
                    label: '名称',
                    name: 'label',
                    validations: {
                        maxLength: 20
                    },
                    required: true
                },
                {
                    type: "radios",
                    label: "单选框",
                    name: "template",
                    required: true,
                    options: [
                        {
                            label: "空白页",
                            value: 0
                        },
                        {
                            label: "列表页",
                            value: 1
                        },
                        {
                            label: "表单页",
                            value: 2
                        },
                        {
                            label: "报表页",
                            value: 3
                        }
                    ]
                },
                {
                    type: 'icon-picker',
                    label: '图标',
                    name: 'icon'
                }
            ]
        }
    },
    ({onConfirm, pages, ...rest}: any) => {
        return {
            ...rest,
            data: {
                pages
            },
            onConfirm: (values: Array<any>) => onConfirm && onConfirm(values[0])
        };
    }
);
